<!-- 单位下拉选择 -->
<template>
  <el-select
    v-model="formData[prop]"
    :placeholder="placeholder"
    clearable
    filterable
    @change="selectChange"
  >
    <el-option
      v-for="op in options"
      :key="op.id"
      :label="op.allocation_num"
      :value="op.id"
    />
  </el-select>
</template>

<script>
// 库位信息 下拉框
import { List } from '@/api/allocation'
// import OrderGroupVue from '@/views/dashboard/components/OrderGroup.vue'
export default {
  name: 'CommoditySelect',
  props: {
    formData: {
      type: Object,
      required: true
    },
    prop: {
      type: [Array, String],
      required: true
    },
    placeholder: {
      type: String,
      default: ''
    },
    itemId: {
      type: [String, Number],
      default: ''
    }
  },
  data() {
    return {
      options: []
    }
  },
  watch: {
    itemId: {
      handler(newValue, oldValue) {
        this.getList()
      },
      deep: true
    }
  },
  created() {
    this.getList()
    // console.log(this.itemId);
  },
  methods: {
    async getList() {
      // if (!this.itemId) return
      const res = await List()
      this.options = res.data.list
      console.log(this.options)
    },
    selectChange(val) {
      this.$emit('event-change', val)
    }
  }
}
</script>
